import {
	createRouter,
	createWebHashHistory,
} from 'vue-router';


export const routerArr = [{
	path: '',
	name: '',
	component: '',
	icon: 'icon-pingtai',
	meta: {
		title: '系统模块',
	},
	children: [{
		path: '/home',
		name: 'home',
		component: () => import( /* webpackChunkName: "admin/js/home" */ '../pages/home/index'),
		meta: {
			title: '首页',
			keepAlive: false,
		}
	}, {
		path: '/echarts',
		name: 'echarts',
		component: () => import( /* webpackChunkName: "admin/js/echarts" */ '../pages/echarts/index'),
		meta: {
			title: 'echarts',
			keepAlive: false,
		},
	}, {
		path: '/3d_gallery',
		name: '3d_gallery',
		component: () => import( /* webpackChunkName: "admin/js/3d_gallery" */
			'../pages/3d_gallery/index'),
		meta: {
			title: '3d_gallery',
			keepAlive: false,
		},
	}]
}];


//二级路由
let childrenRouter = [];
routerArr.forEach((x) => {
	if (x.children && x.children.length) {
		childrenRouter.push(...x.children);
	} else {
		childrenRouter.push(x);
	}
});


//一级路由
const routes = [{
	path: '/',
	redirect: '/home', //重定向
	name: 'layout',
	component: () => import( /* webpackChunkName: "admin/js/layout" */ '../components/common/layout.vue'),
	children: childrenRouter
}]



const router = createRouter({
	history: createWebHashHistory(),
	routes
})

export default router;
